import Vue from 'vue'
import Router from 'vue-router'
// 首页
import Home from '@/pages/home/Home'
// 登录
import Login from '@/pages/login/Login'
// 首页统计组件
import Count from '@/pages/home/components/Count'
// 渲染数据的组件
import User from '@/pages/home/components/User'
import Order from '@/pages/home/components/Order'
import Shop from '@/pages/home/components/Shop'
import ShopClass from '@/pages/home/components/ShopClass'
import Baidu from '@/pages/home/components/Baidu' //百度地图
import Echarts from  "@/pages/home/components/Echarts" //柱状图

// 路由守卫的404页面
import Error from "@/pages/home/Error"
// 商品编辑页面
import ShopEdit from '@/pages/home/components/ShopEdit';
import ShopSee from '@/pages/home/components/ShopSee';

const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

Vue.use(Router)

export default new Router({
  routes: [{
      path: '/',
      name: 'Home',
      component: Home,
      redirect: '/count',
      meta: {
        requtreAuth: true,
        title: "系统首页"
      },
      children: [{
          path: "count",
          name: "Count",
          component: Count,
        },
        {
          path: "user",
          name: "user",
          component: User
        },
        {
          path: "order",
          name: "user",
          component: Order
        },
        {
          path: "shop",
          name: "shop",
          component: Shop
        },
        {
          path: "shopClass",
          name: "ShopClass",
          component: ShopClass
        },
        {
          path: "edit",
          name: "ShopEdit",
          component: ShopEdit
        },
        {
          path: "see",
          name: "ShopSee",
          component: ShopSee
        },
        {
          path: "baidu",
          name: "Baidu",
          component: Baidu
        },
        {
          path: "echarts",
          name:"Echarts",
          component: Echarts,
        }

      ]
    },
    {
      path: '/login',
      name: 'Login',
      component: Login,
      meta: {
        title: "登陆系统"
      }
    },
    {
      path: '/error',
      name: 'Error',
      component: Error,
    },

  ],


})
